
import { IPublicTypeComponentMetadata, IPublicTypeSnippet } from '@alilc/lowcode-types';

const ThreeDPieChartMeta: IPublicTypeComponentMetadata = {
  componentName: 'ThreeDPieChart',
  title: '消防重点点位',
  category: '图表组件',
  group: '消防安全',
  docUrl: '',
  screenshot: '',
  devMode: 'proCode',
  npm: {
    package: 'hzdz-charts',
    version: '0.1.0',
    exportName: 'ThreeDPieChart',
    main: 'src/index.tsx',
    destructuring: true,
    subName: ''
  },
  props: [
    {
      name: 'ref',
      propType: 'object',
    },
    {
      name: 'key',
      propType: 'string',
    },
    {
      name: 'style',
      propType: 'object',
    },
  ],
  configure: {
    props: [
      // 基础配置
      {
        name: 'basic',
        type: 'group',
        display: 'accordion',
        title: {
          label: '基础配置',
        },
        items: [
          {
            name: 'width',
            title: {
              label: '宽度',
              tip: '组件宽度，支持数字或字符串'
            },
            setter: {
              componentName: 'MixedSetter',
              props: {
                setters: [
                  'StringSetter',
                  'NumberSetter'
                ]
              }
            }
          },
          {
            name: 'height',
            title: {
              label: '高度',
              tip: '组件高度，支持数字或字符串'
            },
            setter: {
              componentName: 'MixedSetter',
              props: {
                setters: [
                  'StringSetter',
                  'NumberSetter'
                ]
              }
            }
          },
          {
            name: 'valueField',
            title: {
              label: '值字段',
              tip: '数据中表示数值的字段名'
            },
            setter: 'StringSetter'
          },
          {
            name: 'labelField',
            title: {
              label: '标签字段',
              tip: '数据中表示标签的字段名'
            },
            setter: 'StringSetter'
          },
          {
            name: 'legendPosition',
            title: {
              label: '图例位置',
              tip: '图例的显示位置'
            },
            setter: {
              componentName: 'SelectSetter',
              props: {
                options: [
                  { label: '右侧', value: 'right' },
                  { label: '左侧', value: 'left' },
                  { label: '顶部', value: 'top' },
                  { label: '底部', value: 'bottom' }
                ]
              }
            }
          },
          {
            name: 'textColor',
            title: {
              label: '文字颜色',
              tip: '图例文字的颜色'
            },
            setter: 'ColorSetter'
          },
          {
            name: 'textTilt',
            title: {
              label: '文本倾斜',
              tip: '图例文字是否倾斜显示'
            },
            setter: 'BoolSetter'
          },
          {
            name: 'innerRadius',
            title: {
              label: '内径',
              tip: '饼图内径比例，0-1之间的数值，0为实心饼图，>0为环形图'
            },
            setter: {
              componentName: 'NumberSetter',
              props: {
                min: 0,
                max: 1,
                step: 0.1
              }
            }
          },
          {
            name: 'colorScheme',
            title: {
              label: '配色',
              tip: '饼图的颜色配置，支持多个颜色'
            },
            setter: {
              componentName: 'ArraySetter',
              props: {
                itemSetter: {
                  componentName: 'ColorSetter',
                  initialValue: '#4D74FF'
                }
              }
            }
          }
        ]
      }
    ],
    supports: {
      style: true,
      className: true,
      events: ['onClick']
    }
  }
};
let width = 270
let showIcon = true
const snippets: IPublicTypeSnippet[] = [
  {
    title: '消防重点点位',
    screenshot: '',
    schema: {
      componentName: 'ThreeDPieChart',
      props: {
        width: showIcon ? width + 30 : width, //根据showIcon动态设置
        height: 150,
        valueField: 'value',
        labelField: 'label',
        data: [
          { name: '设备报警', value: 10, color: '#4D74FF' },
          { name: '人品报警', value: 20, color: '#5AF3B8' },
          { name: '119联动', value: 30, color: '#93DBFF' }
        ],
        showIcon: showIcon, // 显示放大镜按钮和图例数字
        chartSize: 120,
        innerRadius: 0,
        height3d: 30,
        tiltAngle: 15,
        colorScheme: ['#4D74FF', '#5AF3B8', '#93DBFF'],
        showLegend: true,
        legendPosition: 'right',
        textColor: '#FFFFFF',
        textTilt: false,
        showLabels: false,
        labelPosition: 'outside',
        labelColor: '#FFFFFF',
        size: 'medium',
        theme: 'dark'
      }
    }
  }
];

export default {
  ...ThreeDPieChartMeta,
  snippets,
};
